﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace amuudp
{
    // 捕获到图片后，需要tcp传输，传输过程如下：
    /* 
     * 一个状态线程，多个图片传输线程
     * 
     * 服务器状态线程：connect
     * 客户端状态线程：connected
     * 
     * 客户端主动向服务器发起请求
     * 客户端：connect:ip=192.168.0.2;
     * 服务器：connected
     * 客户端：info:name=云桌面;width=1920;height=1080;
     * 客户端：[图片]
     * 客户端：[图片]
     * 客户端：[图片]
     * 
     * 服务器主动向
     * 服务器：connect:ip=192.168.0.1;
     * 客户端：connected
     * 客户端：info:name=云桌面;width=1920;height=1080;
     * 客户端：[图片]
     * 客户端：[图片]
     * 客户端：[图片]
     */

    public class CaptureScreen
    {
        // 是否可以捕获图片
        public bool CanCapture { get; private set; }
        public int LocationX { get; private set; }
        public int LocationY { get; private set; }
        public int ScreenWidth { get; private set; }
        public int ScreenHeight { get; private set; }

        public CaptureScreen()
        {

        }

        public void Start()
        {

        }

        public void Stop()
        {

        }

        private Bitmap Capture(int width, int height)
        {
            Bitmap bmp = new Bitmap(width, height);
            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.CopyFromScreen(LocationX, LocationY, 0, 0, new Size(ScreenWidth, ScreenHeight));
            }
            return bmp;
        }
    }
}
